package com.yimiyisu.contract_cust.controller;

import com.zen.*;
import com.zen.annotation.AccessRole;
import com.zen.annotation.Inject;
import com.zen.enums.ZenRole;

import java.util.List;

@AccessRole(ZenRole.ADMIN)
public class Risk extends ZenController {
    @Inject
    private ZenEngine zenEngine;

    /**
     * 上报风险
     */
    public ZenResult addRisk(ZenData data) {
        List<String> noticeList = data.getAsList("notice", String.class);
        ZenResult result = zenEngine.execute("get/contract", ZenData.create("id", data.get("contractId")));
        if(result.get("head") != null){
            noticeList.add(result.get("head"));
        }
        data.put("notice", noticeList);
        zenEngine.execute("put/risk", data);
//        String templateName = "risk";
//        ZenMessage zenMessage = new ZenMessage(templateName);
//        zenMessage.setContent("您有一个风险待处理");
//        zenMessage.setFrom(data.getUid());
//        zenMessage.setTitle("风险");
//        for (String s : noticeList) {
//            String send = zenMessage.send(s);
//        }

        return ZenResult.success();
    }
}
